package com.nehc.nettyserver.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * SpringDoc API文档配置类
 * 基于javadoc的无注解零入侵API文档
 * 
 * @author NEHC
 */
@Configuration
public class SwaggerConfig {

    /**
     * 服务器状态API组
     */
    @Bean
    public GroupedOpenApi serverStatusApi() {
        return GroupedOpenApi.builder()
                .group("服务器状态API")
                .pathsToMatch("/status/**")
                .build();
    }

    /**
     * 消息API组
     */
    @Bean
    public GroupedOpenApi messagesApi() {
        return GroupedOpenApi.builder()
                .group("消息API")
                .pathsToMatch("/messages/**")
                .build();
    }

    /**
     * 通知API组
     */
    @Bean
    public GroupedOpenApi notificationsApi() {
        return GroupedOpenApi.builder()
                .group("通知API")
                .pathsToMatch("/notifications/**")
                .build();
    }

    /**
     * OpenAPI文档信息配置
     */
    @Bean
    public OpenAPI nehcNettyServerOpenAPI() {
        return new OpenAPI()
                .info(new Info().title("NEHC Netty Server API文档")
                        .description("提供服务器状态、消息、通知等接口")
                        .version("1.0.0")
                        .contact(new Contact()
                                .name("NEHC")
                                .url("https://nehc.com")
                                .email("admin@nehc.com"))
                        .license(new License().name("MIT").url("https://opensource.org/licenses/MIT")))
                .externalDocs(new ExternalDocumentation()
                        .description("更多文档")
                        .url("https://nehc.com/docs"));
    }
}